package com.cunshe.web.manage;

import com.cunshe.common.ResponseVO;
import com.cunshe.config.annotation.Login;
import com.cunshe.dao.CompanyProfileDao;
import com.cunshe.domain.CompanyProfile;
import com.cunshe.entity.vo.CompanyProfileUpdateVO;
import com.cunshe.service.CompanyProfileService;
import com.cunshe.web.BaseController;
import com.sunkee.commons.utils.ConvertUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 公司简介
 * @author xiao
 */
@Api(tags = "公司简介")
@Login
@RestController
@RequestMapping(value = "/manage/companyProfile")
public class CompanyProfileController extends BaseController {

    @Autowired
    private CompanyProfileService companyProfileService;

    /** 修改 */
    @ApiOperation(value = "修改")
    @PostMapping(value = "update")
    public ResponseVO update(@RequestBody @Validated CompanyProfileUpdateVO vo) {
        CompanyProfile companyProfile = ConvertUtil.copyProperties(vo, CompanyProfile.class);
        companyProfile.setId(1L);
        companyProfileService.update(companyProfile);
        return ResponseVO.success();
    }

    /** 查询 */
    @ApiOperation(value = "查询")
    @GetMapping(value = "get")
    public ResponseVO get() {
        CompanyProfile companyProfile = companyProfileService.get();
        return ResponseVO.success(companyProfile);
    }

}